package HttpCode

type AppHttpCodeEnum int

const (
	SUCCESS           AppHttpCodeEnum = 200
	NEED_LOGIN        AppHttpCodeEnum = 401
	NO_OPERATOR_AUTH  AppHttpCodeEnum = 403
	SYSTEM_ERROR      AppHttpCodeEnum = 500
	USERNAME_EXIST    AppHttpCodeEnum = 501
	PHONENUMBER_EXIST AppHttpCodeEnum = 502
	EMAIL_EXIST       AppHttpCodeEnum = 503
	REQUIRE_USERNAME  AppHttpCodeEnum = 504
	LOGIN_ERROR       AppHttpCodeEnum = 505
)

// 定义一个map来存储错误码对应的消息
var AppHttpCodeEnumMsg = map[AppHttpCodeEnum]string{
	SUCCESS:           "操作成功",
	NEED_LOGIN:        "需要登录后操作",
	NO_OPERATOR_AUTH:  "无权限操作",
	SYSTEM_ERROR:      "出现错误",
	USERNAME_EXIST:    "用户名已存在",
	PHONENUMBER_EXIST: "手机号已存在",
	EMAIL_EXIST:       "邮箱已存在",
	REQUIRE_USERNAME:  "必需填写用户名",
	LOGIN_ERROR:       "用户名或密码错误",
}

// 获取错误码对应的消息
func (code AppHttpCodeEnum) GetMsg() string {
	return AppHttpCodeEnumMsg[code]
}

// 获取错误码
func (code AppHttpCodeEnum) GetCode() int {
	return int(code)
}
